/*
 * @Author: Olivia
 * @Date: 2022-03-15 15:19:09
 * @LastEditTime: 2023-03-01 21:13:15
 * @FilePath: \toutiao-m\src\api\user.js
 * @custom_string_Olivia: Less is more
 */
/* 用户请求相关模块 */
import request from '@/utils/request'
// import store from '@/store'
/* 用户登录 */
export const login = (data) => {
  return request({
    method: 'post',
    url: '/app/v1_0/authorizations',
    data
  })
}
/* 发送验证码 */
export const sendSms = (mobile) => {
  return request({
    method: 'get',
    url: ` /app/v1_0/sms/codes/${mobile}`
  })
}
/* 发送验证码 */
export const getUserInfo = () => {
  return request({
    method: 'get',
    url: '/app/v1_0/user',
    headers: {
      'Content-Type': 'application/json'
      //   Authorization: 'Bearer ' + `${store.state.user.token}`
    }
  })
}
/* 发送验证码 */
export const getUserChannels = () => {
  return request({
    method: 'get',
    url: '/app/v1_0/user/channels'
  })
}
/* 添加关注
 */
export const addFollow = userId => {
  return request({
    method: 'post',
    url: '/app/v1_0/user/followings',
    data: {
      target: userId
    }
  })
}
/* 取消关注
 */
export const deleteFollow = userId => {
  return request({
    method: 'DELETE',
    url: `/app/v1_0/user/followings/${userId}`
  })
}
/* 获取个人信息
 */
export const getUserProfile = target => {
  return request({
    method: 'get',
    url: '/app/v1_0/user/profile'
  })
}
/* 更新昵称
 */
export const updateName = data => {
  return request({
    method: 'PATCH',
    url: '/app/v1_0/user/profile',
    data
  })
}
/* 更新用户头像
 */
export const updateUserPhoto = data => {
  return request({
    method: 'PATCH',
    url: '/app/v1_0/user/photo',
    data
  })
}

